package com.csx.base.design.structure.proxy.dynamic;

import com.csx.base.design.structure.proxy.Intranet;
import com.csx.base.design.structure.proxy.staticM.RouterProxy;
import com.csx.base.design.structure.proxy.Internet;
import com.csx.base.design.structure.proxy.Switch;

import java.lang.reflect.Proxy;

/**
 * @author cuisongxu
 * @date 2022/9/22 12:19
 */
public class Client {

    public static void main(String[] args) throws Exception {

        Internet internet = (Internet) Proxy.newProxyInstance(
                RouterProxy.class.getClassLoader(),
                RouterProxy.class.getInterfaces(),
                new BlackListFilter(new RouterProxy())
        );

        internet.httpAccess("http://www.电影.com");
        internet.httpAccess("http://www.游戏.com");
        internet.httpAccess("http://www.学习.com");
        internet.httpAccess("http://www.工作.com");
        internet.httpAccess("http://www.音乐.com");


        Intranet intranet = (Intranet) Proxy.newProxyInstance(
                Switch.class.getClassLoader(),
                Switch.class.getInterfaces(),
                new BlackListFilter(new Switch())
        );
        intranet.fileAccess("http://www.电影.com");
        intranet.fileAccess("http://www.游戏.com");
        intranet.fileAccess("http://www.学习.com");
        intranet.fileAccess("http://www.工作.com");
        intranet.fileAccess("http://www.音乐.com");

    }
}
